﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using CloudTaobao.Util;

namespace CloudTaobao
{
    public partial class Settings : PhoneApplicationPage
    {
        AppSettings settings = new AppSettings();
        App app = Application.Current as App;
        public Settings()
        {
            InitializeComponent();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            if (isShowPicNoWIFI.SelectedIndex == 1)
            {
                settings.isShowPicNoWIFI = true;
                app.isShowPicNoWIFI = true;
            }
            else
            {
                settings.isShowPicNoWIFI = false;
                app.isShowPicNoWIFI = false;
            }

            if (recordsNoWIFI.Text != "" && recordsNoWIFI.Text != "0")
            {
                settings.recordsNoWIFI = Convert.ToInt32(recordsNoWIFI.Text);
                app.recordsNoWIFI = Convert.ToInt32(recordsNoWIFI.Text);
            }
            else
            {
                settings.recordsNoWIFI = 10;
                app.recordsNoWIFI = 10;
            }
            if (records.Text != "" && records.Text != "0")
            {
                settings.records = Convert.ToInt32(records.Text);
                app.records = Convert.ToInt32(records.Text);
            }
            else
            {
                settings.records = 10;
                app.records = 10;
            }
            NavigationService.GoBack();
        }

        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            if (settings.isShowPicNoWIFI)
                isShowPicNoWIFI.SelectedIndex = 1;
            else
                isShowPicNoWIFI.SelectedIndex = 0;
            recordsNoWIFI.Text = "" + settings.recordsNoWIFI;
            records.Text = "" + settings.records;
        }
    }
}